package com.hy.config;

import javax.servlet.MultipartConfigElement;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置图片参数
 * @return
 */
@Configuration
public class MultipartFileConfig {

	@Value("${multipart_file_size}")
    private String fileSize;
    @Bean
    public MultipartConfigElement multipartConfigElement(){
        MultipartConfigFactory factory = new MultipartConfigFactory();
        System.out.println("fileSize---->"+fileSize);
        //文件最大
        factory.setMaxFileSize(fileSize); //KB,MB
        //设置总上传数据总大小
        factory.setMaxRequestSize(fileSize);
        return factory.createMultipartConfig();
    }
}
